<div class="page-header d-print-none">
    <div class="container-xl">
        <div class="row g-2 align-items-center">
            <div class="col">
                <h2 class="page-title" id="title">待审核的帖子</h2>
                <div class="text-muted mt-1" id="article_count">帖子数量：123</div>
            </div>
        </div>
    </div>
</div>
<div class="page-body">
    <div class="container-xl">
        <div class="row justify-content-center">
            <div class="col-12">
                <div class="card">
                    <div class="card-body">
                        <div class="divide-y" id="article-items-body">
                            <!-- 动态生成帖子列表 -->

                            <!-- <div>
                                <div class="row">
                                  <div class="col-auto">
                                    <span class="avatar" style="background-image: url(image/avatar01.jpeg)"></span>
                                  </div>  
                                  <div class="col">
                                    <div class="text-truncate">
                                      <a href="javascript:void(0);" class="examine_article_list_a_title">
                                        <strong> 标题 </strong>
                                      </a>
                                    </div>
                                    <div class="text-muted mt-2">
                                      <div class="row">
                                        <div class="col">
                                          <ul class="list-inline list-inline-dots mb-0">
                                            <li class="list-inline-item">
                                              <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-user"
                                                width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
                                                fill="none" stroke-linecap="round" stroke-linejoin="round">
                                                <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                                <path d="M12 7m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0"></path>
                                                <path d="M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"></path>
                                              </svg>
                                              昵称
                                            </li>
                                            <li class="list-inline-item">
                                                <svg xmlns="http://www.w3.org/2000/svg"
                                                  class="icon icon-tabler icon-tabler-clock-edit" width="24" height="24"
                                                  viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
                                                  stroke-linecap="round" stroke-linejoin="round">
                                                  <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                                  <path d="M21 12a9 9 0 1 0 -9.972 8.948c.32 .034 .644 .052 .972 .052"></path>
                                                  <path d="M12 7v5l2 2"></path>
                                                  <path d="M18.42 15.61a2.1 2.1 0 0 1 2.97 2.97l-3.39 3.42h-3v-3l3.42 -3.39z"></path>
                                                </svg>
                                                时间
                                              </li>
                                          </ul>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                            </div> -->

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $.ajax({
            url: '/article/getExamineList?getAll=true',
            type: 'get',
            success: function(respData) {
                if (respData.code == 0) {
                buildProfileUserExamineArticle(respData.data);
                } else {
                $.toast({
                    heading: '警告',
                    text: respData.message,
                    icon: 'warning'
                });
                }
            },
            error : function() {
                $.toast({
                    heading: '错误  ',
                    text: '访问出现问题，请与管理员联系.',
                    icon: 'error'
                });
            }
        });

        function buildProfileUserExamineArticle(data) {
            // 没有帖子
            if(data.length == 0) {
                $('#article-items-body').html('暂无！');
                return;
            }

            data.forEach(article => {
                // 设置默认头像
                if (!article.user.avatarUrl) {
                    article.user.avatarUrl = avatarUrl;
                }

                let articleHtmlStr = '<div>'
                    + '<div class="row">'
                    + '<div class="col-auto">'
                    + '<span class="avatar" style="background-image: url('
                    + article.user.avatarUrl
                    + ')"></span>'
                    + '</div>  '
                    + '<div class="col">'
                    + '<div class="text-truncate">'
                    + '<a href="javascript:void(0);" class="examine_article_list_a_title">'
                    + '<strong>'
                    + article.title
                    + '</strong>'
                    + '</a>'
                    + '</div>'
                    + '<div class="text-muted mt-2">'
                    + '<div class="row">'
                    + '<div class="col">'
                    + '<ul class="list-inline list-inline-dots mb-0">'
                    + '<li class="list-inline-item">'
                    + '<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-user"'
                    + 'width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"'
                    + 'fill="none" stroke-linecap="round" stroke-linejoin="round">'
                    + '<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>'
                    + '<path d="M12 7m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0"></path>'
                    + '<path d="M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"></path>'
                    + '</svg>'
                    + article.user.nickname
                    + '</li>'
                    + '<li class="list-inline-item">'
                    + '<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-history" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 8l0 4l2 2" /><path d="M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5" /></svg>'
                    + article.updateTime
                    + '</li>'
                    + '</ul>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    + '</div>';

                let profileArtilceItem = $(articleHtmlStr);
                // 获取标题的 a 标签
                let articleTitle = profileArtilceItem.find('.examine_article_list_a_title');
                // 处理标题点击事件
                articleTitle.click(function() {
                    // 通过全局变量保存当前访问的帖子信息
                    currentArticle = article;
                    $('#forum-content').load('examine_detail.html');
                });
                // 追加到父标签
                $('#article-items-body').append(profileArtilceItem);
            });
        }
    });
</script>